<?php
namespace app\blog\controller;
use app\blog\model\BlogArticle as ArticleModel;
use app\blog\model\BlogClassify as ClassifyModel;
use app\blog\model\BlogClassifyTwo as ClassifyTwoModel;
use app\blog\model\InfoUser as UserModel;
use think\Controller;
use think\Db;
class Index extends Controller
{
    //载入博客主页
    public function index()
    {
        //查询文章一级类别信息
       $data=ClassifyModel::all();
        //查询文章二级类别信息
        $class=ClassifyTwoModel::select();
       //查询文章信息
       $list=ArticleModel::select();
       //查询用户信息
       $user=UserModel::select();
       //按照文章点赞前五条显示文章标题
       $support=ArticleModel::order('support','desc')->limit(5)->column('title');
       //按照文章浏览顺序显示
       $this->assign('data',$data);
       $this->assign('list',$list);
       $this->assign('user',$user);
       $this->assign('support',$support);
       $this->assign('class',$class);
       return $this->fetch();
    }
    //退出登录方法
    public function logout()
    {

        session('cj',null);
        session('id',null);
        $this->success('您已退出','/blog','','1');

    }
}